package cn.iune.system.config;

import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.stereotype.Service;

import cn.iune.backcenter.author.sysinfo.ISysInfoService;
import cn.iune.backcenter.author.sysinfo.SysInfo;
import cn.iune.system.spring.SpringUtils;


@Service
public class SysInfoCache {
	
	Logger log = LogManager.getLogger(this.getClass());

//	@Autowired
	private ISysInfoService sysInfoService;
//	@Autowired
//	private IBillSettingService billSettingService;
	
	
	public SysInfoCache() {
		log.info("SysInfoCache构造函数执行");
	}
	
	private List<SysInfo> pagList = new ArrayList<SysInfo>();
//	private List<BillSetting> billSettingList = new ArrayList<BillSetting>();
//	private JSONObject sysInfoJson = new JSONObject();

	public List<SysInfo> getPagList() {
		return pagList;
	}

	/*
	public List<BillSetting> getBillSettingList() {
		return billSettingList;
	}

	public JSONObject getSysInfoJson() {
		return sysInfoJson;
	}
	*/
	

	
	@PostConstruct  //项目启动时会执行这个方法加载数据
	public void init() {
		System.out.println("SysInfoCache.init函数执行");
		
		//这里可以根据本服务器节点所部署的应用列表进行加载，进而获取appId，暂时未开发。。。。。。
		//加载页面列表
		sysInfoService = SpringUtils.getBean(ISysInfoService.class);
//		pagList = sysInfoService.getPagList(appId);
		pagList = sysInfoService.getPagList();
		System.out.println("SysInfoCache-->>加载页面列表完成。");
		
		/*
		//加载单据类型列表
		billSettingList = billSettingService.getList(appId);
		System.out.println("加载单据类型列表");
		//加载全部树形菜单列表
		JSONObject param = new JSONObject();
//		String columns = EntityToDefColJSON.doit(SysInfo.class);
//		JSONObject col = JSONObject.parseObject(columns);
//		param.put("columns", col);
		param.put("offset", 0);
		param.put("limit", -1);
		String filter = "SysInfo.appId='"+appId+"'";
		param.put("filter", filter);
		param.put("orderBy", "sortNo ASC");
		sysInfoJson = sysInfoService.queryData(param);
		//System.out.println("sysInfoJson-->>"+sysInfoJson.toJSONString());
		System.out.println("加载系统信息");
		*/
	}

	
	
	
}
